package tpi.gui.pages.pantallafinal

import org.apache.wicket.markup.html.WebPage
import tpi.gui.model.Investigacion
import org.uqbar.wicket.xtend.WicketExtensionFactoryMethods
import org.apache.wicket.Component
import org.apache.wicket.markup.html.form.Form
import org.apache.wicket.model.CompoundPropertyModel
import org.uqbar.wicket.xtend.XButton
import tpi.gui.pages.InicioPage
import dominio.factory.FactoryGame
import org.apache.wicket.markup.html.basic.Label
import org.apache.wicket.model.PropertyModel

abstract class PantallaFinalPage extends WebPage {
	
	extension WicketExtensionFactoryMethods = new WicketExtensionFactoryMethods
	private final Investigacion investigacion
	private final Boolean gano
	private Form<Investigacion> form
	
	new(Investigacion investigacion, Boolean gano) {
		this.investigacion = investigacion
		this.gano = gano
		this.defaultModel = investigacion.asCompoundModel
		
		form = new Form<Investigacion>("finalForm", new CompoundPropertyModel(this.investigacion))

		if (!gano) form.addChild(new Label("responsable", new PropertyModel(this.investigacion,"caso.responsable")))
		form.addChild(new Label("buscado", new PropertyModel(this.investigacion,"ordenDeArresto.responsable")))
		form.addChild(new XButton("reiniciar").onClick = [| reiniciar()])
		addChild(form)
	}
	
	def reiniciar() {
		responsePage = new InicioPage
	}
	
}